<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>证件补录</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
        	<div class="FXBR">
	            <div class="fieldBox">
	                <div class="label">客户名称</div>
	                <div class="field">
	                    <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
	            </div>
	            <div class="fieldBox">
	                <div class="label">证件号码</div>
	                <div class="field">
	                    <input name="certNo" id="certNo" type="text" class="ui-textbox" value="" ligerui="width: 160">
	                </div>
	            </div>
            </div>
            
            <div class="clearFix"></div>
	            <div class="btnsBox formBtns notRight">
	               <span id="searchBtn" class="sq-button-round">查询</span>
	               <span id="clearBtn" class="sq-button-round">清空</span>
	               <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
	            </div>
        	</div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>
</div>
<script type="text/javascript">
	var grid = null
	$(function () {
	    initForm();
		initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
	    searchBtnEvent();
	    clearBtnEvent();
	});
	
	//清空按钮事件
	function clearBtnEvent(){
		 $("#clearBtn").click(function(event) {
		        $("#resetBtn").click();  //重置 input-text
		        var form = liger.get("searchBar");
		 });
	}
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询按钮事件
	function searchBtnEvent(){
		 $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#ligergrid1").ligerGrid({
	    	url: '<%=path%>/customer/cstbscinfo/initList.do?cstTypCd=1',
	    	method : 'get',
	    	parms:getSearchParams(),
	        columns: [
	            { display: '客户名称', name: 'cstNm', minWidth: 180 , align:'center', enabledSort:true,
	            	render: function (rowdata, rowindex, value, column) { 
	            		if(StringUtils.isEmpty(value)){
	                		value = "";
	                	}
	            		var h = '';
	            		    h='<a href="javascript:showDetail(';
	                        h+="'"+rowdata.id+"'";
	                        h+=",'"+rowdata.cstTypCd+"'";
	                        h+=')">'+value+'</a>'
	                        return h;
	            		}},
	            { display: '客户性质', name: 'cstStsCdNm', width: 120, enabledSort:true },
	            { display: '客户类型', name: 'cstTypCd', width: 1,align:'left', enabledSort:true, hide:true},
	            { display: '客户类型', name: 'cstTypCdNm', width: 120, enabledSort:true},
	            { display: '证件/组织机构代码', name: 'certNo', width: 160, align:'center', enabledSort:true},
	            { display: '创建时间', name: 'crtTm', width: 180 , render:renderDate, enabledSort:true},
				{ display: '操作',isSort: false,width: 100,align:'center',
					render: function (rowdata, rowindex, value){
						var h = '';
                        h='<a href="javascript:initCstFileListByDataId(';
                        h+="'"+rowdata.id+"'";
                        h+=')">上传身份证</a>'
                        return h;
					}
				}
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : false,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        rownumbers:true
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    grid.options.isSingleCheck=true;
	}

	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}

	//查看数据
	function showDetail(_id,_cstTypCd){
		//1 自然人  2 法人
		if(_cstTypCd == 1){
			parent.mainApp.f_addTab('tab_customer_np_detail'+_id,'客户详情','<%=path%>/customer/cstbscinfo/toCustCstBacInfoNpDetailPage.do?id='+_id);
		}else if(_cstTypCd == 2){
			parent.mainApp.f_addTab('tab_customer_corp_detail'+_id,'客户详情','<%=path%>/customer/cstbscinfo/toCustCstBacInfoCorpDetailPage.do?id='+_id);
		}
	}

	function initCstFileListByDataId(dataId){
		$.ligerDialog.open({
			title: '客户附件上传',
			height: 500,
			width: 850,
			url: '<%=path%>/customer/cstbscinfo/toCustCstBscInfoFileDetail.do?dataId=' + dataId
		});
	}

	//选择客户页面
	function chooseCstPage() {
		var cstRlFlag = ProjectConstant.CST_RL_CST;//客户
		var addPrjPage = "1";

	}


	function clearBtn(){
		var form = new liger.get("searchBar");
		form.clear();
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
</script>

</body>
</html>